package com.su.song.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.su.song.myapplication.Util.DataUtil;

public class MainActivity_enable extends AppCompatActivity implements View.OnClickListener {

    private TextView tv_test;
    private Button btn_test;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_enable);
        Button btn_able = findViewById(R.id.btn_able);
        Button btn_enable = findViewById(R.id.btn_enable);
        btn_test = findViewById(R.id.btn_test);
        tv_test = findViewById(R.id.tv_test);


        btn_able.setOnClickListener(this);
        btn_enable.setOnClickListener(this);
        btn_test.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_able:
                btn_test.setEnabled(true);
                break;
            case R.id.btn_enable:
                btn_test.setEnabled(false);
                break;
            case R.id.btn_test:
                String desc = String.format("%s 您点击了按钮: %s", DataUtil.getNowTime(),((Button) v).getText());
                tv_test.setText(desc);
        }
    }
}